/*
This file is used as a common base style for markdown text rendering.
It is included in the global base styles in PDF rendering and in the markdown preview in the frontend.
*/


/* Component base styles for component layout */
table {
  width: 100%;
  caption-side: bottom;
}
table, th, td {
  border: 1px solid black;
  border-collapse: collapse;
}
th {
  font-weight: bold;
}
td {
  overflow-wrap: anywhere;
  word-break: break-all;
}
th, td {
  padding: 0.3em;
}
tr {
  break-inside: avoid;
}
thead {
  break-inside: avoid;
  break-after: avoid;
}
caption {
  font-weight: bold;
  break-inside: avoid;
  break-before: avoid;
}
table img {
  display: block;
  margin-left: auto;
  margin-right: auto;
}


/* Images and figures */
figure {
  break-inside: avoid;
  text-align: center;
  margin-left: 0;
  margin-right: 0;
}
figcaption {
  font-weight: bold;
  break-inside: avoid;
  break-before: avoid;
}
img {
  max-width: 100%;
}


/* Code blocks */
pre code {
  display: block;
}
/* Allow line wrapping in code blocks: prevent code from overflowing page */
pre {
  white-space: pre-wrap;
}






/* Markdown text styles */
h1 { font-size: 2rem;  }
h2 { font-size: 1.6rem; }
h3 { font-size: 1.4rem; }
h4 { font-size: 1.25rem; }
h5 { font-size: 1.1rem; }
h6 { font-size: 1rem; }

h1, h2, h3, h4, h5, h6 {
  font-weight: bold;
  margin: 1em 0 0.4em 0;
}

p, ul, ol, blockquote, table, .code-block, .markdown {
  margin: 0 0 0.8em 0;
  padding: 0;
}
p:last-child, ul:last-child, ol:last-child, blockquote:last-child, table:last-child, .code-block:last-child, .markdown:last-child {
  margin-bottom: 0;
}


blockquote {
  background-color: #f9f9f9;
  border-left: 5px solid #ccc;
  padding: 0.1em 0.5em;
}


ul li, ol li {
  margin-left: 1.5em;
  padding-left: 0;
}
ul li.task-list-item {
  list-style-type: none;
}
input[type="checkbox" i] {
  display: inline-block;
  appearance: none;
  position: relative;
  box-sizing: border-box;
  font-size: 1em;
  width: 1em;
  height: 1em;
  vertical-align: -.2em;
  border: 0.05em solid currentColor;
  border-radius: 0.2em;
  margin: 0;
  margin-left: -1.35em;
  margin-right: 0.15em;
  padding: 0;
}
input[type="checkbox" i][checked]::before {
  content: initial;
}
input[type="checkbox" i][checked]::after {
  content: '';
  box-sizing: border-box;
  display: block;
  width: 0.4em;
  height: 0.8em;
  border-color: currentColor;
  border-style: solid;
  border-width: 0 0.2em 0.2em 0;
  transform: translateX(0.25em) rotate(40deg);
}

pre {
  white-space: pre-wrap;
}
code {
  padding: 0.2em;
  border-radius: 3px;
  font-family: monospace;
  font-size: 0.85em;
  background-color: rgb(240, 240, 240);
}
pre code {
  padding: 1em; /* Conflicts with syntax highlighting "pre code.hljs" padding. For now both have to have the same value. */
  display: block;
}

/* Mermaid diagrams */
.mermaid-diagram {
  display: inline-block;
  width: 100%;
  height: 100%;
}
.mermaid-diagram img, .mermaid-diagram svg {
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 23cm; /* prevent text from overflowing page, approximation because we do not have access to the actual page content height */
  object-fit: contain;
}
